package com.cloud.manager.core.result;

/**
 * 描述：
 *
 * @author FineEx   2021/11/30
 * @version 1.0
 */
public class ResultCreator {
    private final static String SUCCESS = "success";

    public static <T> Result<T> success() {
        Result<T> result = new Result<T>();
        result.setCode(Result.Code.SUCCESS.code);
        result.setMessage(SUCCESS);
        return result;
    }

    public static <T> Result<T> success(T data) {
        Result<T> result = new Result<T>();
        result.setCode(Result.Code.SUCCESS.code);
        result.setMessage(SUCCESS);
        result.setData(data);
        return result;
    }

    public static <T> Result<T> fail(String message) {
        Result<T> result = new Result<T>();
        result.setCode(Result.Code.FAIL.code);
        result.setMessage(message);
        return result;
    }

    public static <T> Result<T> fail(int code, String message) {
        Result<T> result = new Result<T>();
        result.setCode(code);
        result.setMessage(message);
        return result;
    }

    public static <T> Result<T> fail(int code, String message, T data) {
        Result<T> result = new Result<T>();
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }
}
